package com.itheima.FoodCase;

import java.util.ArrayList;
import java.util.Scanner;

/**
 * @ClassName FOODManager
 * @Author 16799
 * @Date 2025/7/1 10:26
 * @Version 1.0
 * @Description TODO
 *
 * 自己写一遍arraylist包下面的黑马案例,所以就不写注释了
 **/
public class FOODManager {
    private ArrayList<FOOD> foodArrayList = new ArrayList<>();
    Scanner sc = new Scanner(System.in);

    public void addFOOD(){
        FOOD f = new FOOD();
        System.out.println("输入菜名");
        f.setName(sc.next());

        System.out.println("输入菜价格");
        f.setPrice(sc.nextDouble());

        System.out.println("输入菜的介绍");
        f.setInformation(sc.next());

        foodArrayList.add(f);
        System.out.println("菜品上架成功");
    }

    public void showFOODS(){
        if (foodArrayList.size()==0){
            System.out.println("还没有菜品上架");
            return;
        }
        for (int i = 0; i < foodArrayList.size(); i++) {
            FOOD food = foodArrayList.get(i);
            System.out.println(food.getName());
            System.out.println(food.getOriginalPrice());
            System.out.println(food.getInformation());
        }
    }

    public void start(){
        while (true){
            System.out.println("引用类型foodArrayList的地址输出为："+foodArrayList);
            System.out.println("请选择功能：");
            System.out.println("1、上架菜品");
            System.out.println("2、展示菜品");
            System.out.println("3、退出");

            System.out.println("请选择您的操作：");
            String command = sc.next();
            switch (command){
                case "1":
                    addFOOD();
                    break;
                case "2":
                    showFOODS();
                    break;
                case "3":
                    System.out.println("下次再来");
                    return;
                default:
                    System.out.println("输入的号码错误");
            }
        }
    }

}
